#ifndef B508F205_F739_4322_8A3C_2E0BFFB3AE14
#define B508F205_F739_4322_8A3C_2E0BFFB3AE14

#include "main.h"


#define IIC_WR 0 /* 写控制bit */
#define IIC_RD 1 /* 读控制bit */

enum
{
    IIC_STATE_NONE = 0,
    IIC_STATE_TX_START,
    IIC_STATE_TX_ADDR_WAIT,
    IIC_STATE_TX_BYTE_WAIT,


    IIC_STATE_RX_START,
    IIC_STATE_RX_ADDR_WAIT,
};

enum
{
    IIC_WRITE_OK = 0,
    IIC_READ_OK,
    IIC_WRITE_FAIL,
    IIC_READ_FAIL,
};

void iic_init(void);
void iic_start(void);
void iic_stop(void);
void iic_sendbyte(unsigned char _ucByte);
unsigned char iic_readbyte(void);
unsigned char iic_waitack(void);
void iic_ack(void);
void iic_nack(void);
unsigned char iic_checkdevice(unsigned char _Address);
void iic_read_bytes(unsigned char addr, unsigned char* data, unsigned char len,unsigned short timeout);
void iic_write_bytes(unsigned char addr,unsigned char* data,unsigned char len,unsigned short timeout);
void iic_callback(unsigned char error);
void iic_master_loop(void*p);
#endif /* B508F205_F739_4322_8A3C_2E0BFFB3AE14 */
